'use strict'

/**
 * <--    还原前    -->
var a = 123;

;

var b = 456;
 * 
 * <--    特点    -->
 * 空语句，有statem（比如表达式、变量声明语句以`;`结尾）
 * 直接移除，方便阅读
 * 
 * <--    解决办法    -->
 * EmptyStatement
 * 
 * <--    冗余判断    -->
 * 无
 * 
 * <--    还原后    -->
`var a = 123;
var b = 456;`
 * 
 **/

const {parse} = require('@babel/parser');
const traverse = require('@babel/traverse').default;
const t = require('@babel/types');
const generator = require('@babel/generator').default;

let xcode = `var a = 123;

;

var b = 456;;`;

const visitor = {
    EmptyStatement:{
        enter:function(path){
            path.remove();
        },
    },
}

let ast = parse(xcode);
traverse(ast, visitor);
let {code} = generator(ast, {retainLines: false, comments: false});
console.log(code);
